package com.kgame5.xtank3d.effect.myemitters {
import kgame5.k3d.core.math.Vector3D;
import kgame5.k3d.core.obj3d.node3d.Node3D;
import kgame5.k3d.pars.myflint.geom.Vector3DFlint;
import kgame5.k3d.pars.myflint.zones.MyDiscZone;
import kgame5.k3d.pars.myflint.zones.Zone3D;
import kgame5.kgu.spacial.SpacialManager;
import kgame5.kmath.MathDG;

import com.kgame5.xtank3d.effect.MyEmitter;
import com.kgame5.xtank3d.resource.ResourceManagerX;

/**
 * @author kk
 * 炮弹爆炸，炸出坦克的血液，这个用flint粒子系统做就很好实现
 */
public class TankHurtChipsEmitter extends MyEmitter{
	
	public function TankHurtChipsEmitter(bp:Vector3D,tp:Vector3D) {
		var tankHeight:int=35;
		//碎片产生的区域
		var pZone:Zone3D=new MyDiscZone(Vector3DFlint.ZERO,
										Vector3DFlint.AXISY,20,5);
		
		//爆炸中心
		var count:int=MathDG.random(2,3);
		for(var i:int=0;i<count;i++){
			
			//碎片模型
			var md:Node3D=ResourceManagerX.getInstance().getTankHurtChip();
			
			//位置
			var p:Vector3DFlint=pZone.getLocation();
			md.posi.fill(p.x,tankHeight,p.z);
			
			//速度
			var v:Vector3D=tp.clone();
			v.sub(bp);
			//T.p("碎片速度",v);
			var speedMag:int=MathDG.linearFunc(v.magnitude(),24,128);//this.getExplorSpeed(v.magnitude(),128,24);
			v.normalize();
			v.mul(speedMag);
			v.y=5;
			//T.p(v);
			md.velo.copy(v);
			
			//加速度
			md.ti.hardVO.v3d_a.y=SpacialManager.G;
			
			//生命
			md.life=-1;//落地
			
			
		
			//--添加到世界
			md_g.addChild(md);
		}
	}
}
}
